home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
shfileop
/
shfileop.frm
< prev
next >
Wrap
Text File
|
1996-07-06
|
11KB
|
339 lines
VERSION 4.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "Form1"
ClientHeight = 6735
ClientLeft = 2565
ClientTop = 1440
ClientWidth = 7110
Height = 7140
Left = 2505
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6735
ScaleWidth = 7110
ShowInTaskbar = 0 'False
Top = 1095
Width = 7230
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "E&xit"
Height = 375
Left = 3000
TabIndex = 7
Top = 4560
Width = 1095
End
Begin VB.CommandButton cmdExecute
Caption = "&Delete"
Height = 375
Index = 2
Left = 3000
TabIndex = 6
Top = 3840
Width = 1095
End
Begin VB.CommandButton cmdExecute
Caption = "&Move >>"
Height = 375
Index = 1
Left = 3000
TabIndex = 5
Top = 3360
Width = 1095
End
Begin VB.CommandButton cmdExecute
Caption = "&Copy >>"
Height = 375
Index = 0
Left = 3000
TabIndex = 4
Top = 2880
Width = 1095
End
Begin VB.FileListBox lstFile
Height = 2595
Index = 1
Left = 4200
TabIndex = 11
Top = 2640
Width = 2775
End
Begin VB.DriveListBox cboDrive
Height = 315
Index = 1
Left = 4200
TabIndex = 9
Top = 360
Width = 2775
End
Begin VB.DirListBox lstDir
Height = 1830
Index = 0
Left = 120
TabIndex = 2
Top = 720
Width = 2775
End
Begin VB.DriveListBox cboDrive
Height = 315
Index = 0
Left = 120
TabIndex = 1
Top = 360
Width = 2775
End
Begin VB.FileListBox lstFile
Height = 2595
Index = 0
Left = 120
MultiSelect = 2 'Extended
TabIndex = 3
Top = 2640
Width = 2775
End
Begin VB.Frame Frame2
Caption = "Options"
Height = 1335
Left = 120
TabIndex = 12
Top = 5280
Width = 6855
Begin VB.CheckBox chkShowFile
Caption = "Show Name of Each File"
Height = 255
Left = 3360
TabIndex = 19
Top = 720
Value = 1 'Checked
Width = 2175
End
Begin VB.CheckBox chkConfirmMkDir
Caption = "Confirm Create Directory"
Height = 255
Left = 3360
TabIndex = 18
Top = 480
Width = 2415
End
Begin VB.CheckBox chkConfirmOp
Caption = "Confirm Operations"
Height = 255
Left = 3360
TabIndex = 17
Top = 240
Value = 1 'Checked
Width = 2415
End
Begin VB.CheckBox chkRename
Caption = "Rename on Collision"
Height = 255
Left = 240
TabIndex = 16
Top = 960
Width = 2175
End
Begin VB.CheckBox chkShowDlg
Caption = "Display Progress Dialog"
Height = 255
Left = 240
TabIndex = 15
Top = 720
Value = 1 'Checked
Width = 2175
End
Begin VB.CheckBox chkUndo
Caption = "Allow Undo"
Height = 255
Left = 240
TabIndex = 14
Top = 480
Value = 1 'Checked
Width = 2175
End
Begin VB.CheckBox chkEntireDir
Caption = "Include Entire Directory"
Height = 255
Left = 240
TabIndex = 13
Top = 240
Width = 2175
End
End
Begin VB.DirListBox lstDir
Height = 1830
Index = 1
Left = 4200
TabIndex = 10
Top = 750
Width = 2775
End
Begin VB.Label Label4
Caption = "Destination:"
Height = 255
Left = 4200
TabIndex = 8
Top = 120
Width = 2775
End
Begin VB.Label Label3
Caption = "Source:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 2775
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
'This demo shows some of the features of the Windows 95 API
'Specifically, it uses the SHFileOperation function. This code
'accompanies the Programming Techniques column (October Visual
'Basic Programmer's Journal).
'
'By Jonathan Wood, SoftCircuits 1996 (http://www.softcircuits.com)
'
'Notes:
'-As explained in the October column, Visual Basic 4 cannot take
' full advantage of SHFileOperation becuase of UDT-alignment
' issues. Specifically, the SHFILEOPSTRUCT UDT cannot be declared
' and constructed exactly as required by SHFileOperation and only
' the first 5 members are valid. For example, SHFileOperation
' shows the name of each file being processed unless you specify
' FOF_SIMPLEPROGRESS. If this flag is specified, the function
' takes a message in lpszProgressTitle. You cannot currently do
' this from Visual Basic.
Option Explicit
'SHFileOperation declarations
Const FO_MOVE = 1
Const FO_COPY = 2
Const FO_DELETE = 3
Const FO_RENAME = 4
Const FOF_MULTIDESTFILES = &H1 'Destination specifies multiple files
Const FOF_SILENT = &H4 'Don't display progress dialog
Const FOF_RENAMEONCOLLISION = &H8 'Rename if destination already exists
Const FOF_NOCONFIRMATION = &H10 'Don't prompt user
Const FOF_WANTMAPPINGHANDLE = &H20 'Fill in hNameMappings member
Const FOF_ALLOWUNDO = &H40 'Store undo information if possible
Const FOF_FILESONLY = &H80 'On *.*, don't copy directories
Const FOF_SIMPLEPROGRESS = &H100 'Don't show name of each file
Const FOF_NOCONFIRMMKDIR = &H200 'Don't confirm making any needed dirs
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String 'Used only if FOF_SIMPLEPROGRESS specified
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Sub chkEntireDir_Click()
lstFile(0).Enabled = Not CBool(chkEntireDir)
End Sub
'Executes SHFileOperation with current options
Private Sub cmdExecute_Click(Index As Integer)
Dim FileOp As SHFILEOPSTRUCT
'Parent window of dialog box--just use 0
FileOp.hwnd = 0